/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('partnerintl', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model ResultValue = {
  supplierName?: string(name='SupplierName'),
  supplierWebSite?: string(name='SupplierWebSite'),
  supplierDescription?: string(name='SupplierDescription'),
}

model DescribeProductRequest {
  callerBid?: string(name='CallerBid'),
  callerParentId?: long(name='CallerParentId'),
  callerType?: string(name='CallerType'),
  callerUid?: long(name='CallerUid'),
  clientIp?: string(name='ClientIp'),
  code?: string(name='Code'),
  eagleEyeRpcId?: string(name='EagleEyeRpcId'),
  eagleEyeTraceId?: string(name='EagleEyeTraceId'),
  eagleEyeUserData?: string(name='EagleEyeUserData'),
  ownerId?: long(name='OwnerId'),
  queryDraft?: boolean(name='QueryDraft'),
  requestId?: string(name='RequestId'),
  securityToken?: string(name='SecurityToken'),
  sourceIp?: string(name='SourceIp'),
  stsTokenCallerBid?: long(name='StsTokenCallerBid'),
  stsTokenCallerUid?: long(name='StsTokenCallerUid'),
  stsTokenPrincipalId?: string(name='StsTokenPrincipalId'),
  stsTokenRoleId?: long(name='StsTokenRoleId'),
  stsTokenUserId?: long(name='StsTokenUserId'),
  userId?: long(name='UserId'),
}

model DescribeProductResponseBody = {
  code?: string(name='Code'),
  errorCode?: string(name='ErrorCode'),
  forceFatal?: boolean(name='ForceFatal'),
  httpCode?: string(name='HttpCode'),
  isSuccess?: boolean(name='IsSuccess'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
  result?: {
    auditFailMsg?: string(name='AuditFailMsg'),
    auditStatus?: string(name='AuditStatus'),
    auditTime?: long(name='AuditTime'),
    code?: string(name='Code'),
    description?: string(name='Description'),
    frontCategoryId?: long(name='FrontCategoryId'),
    gmtCreated?: long(name='GmtCreated'),
    gmtModified?: long(name='GmtModified'),
    name?: string(name='Name'),
    picUrl?: string(name='PicUrl'),
    productExtras?: [ 
      {
        key?: string(name='Key'),
        label?: string(name='Label'),
        order?: int32(name='Order'),
        type?: string(name='Type'),
        values?: any(name='Values'),
      }
    ](name='ProductExtras'),
    productSkus?: [ 
      {
        chargeType?: string(name='ChargeType'),
        code?: string(name='Code'),
        constraints?: string(name='Constraints'),
        hidden?: boolean(name='Hidden'),
        modules?: [ 
          {
            code?: string(name='Code'),
            id?: string(name='Id'),
            name?: string(name='Name'),
            properties?: [ 
              {
                conversion?: string(name='Conversion'),
                customContaint?: string(name='CustomContaint'),
                displayName?: string(name='DisplayName'),
                displayUnit?: string(name='DisplayUnit'),
                group?: string(name='Group'),
                isNeedTransmit?: boolean(name='IsNeedTransmit'),
                isShow?: boolean(name='IsShow'),
                isUpgrade?: boolean(name='IsUpgrade'),
                key?: string(name='Key'),
                name?: string(name='Name'),
                order?: long(name='Order'),
                propertyValues?: [ 
                  {
                    displayName?: string(name='DisplayName'),
                    max?: string(name='Max'),
                    min?: string(name='Min'),
                    remark?: string(name='Remark'),
                    step?: string(name='Step'),
                    type?: string(name='Type'),
                    value?: string(name='Value'),
                  }
                ](name='PropertyValues'),
                remark?: string(name='Remark'),
                showType?: string(name='ShowType'),
                unit?: string(name='Unit'),
              }
            ](name='Properties'),
          }
        ](name='Modules'),
        name?: string(name='Name'),
        orderPeriods?: [ 
          {
            name?: string(name='Name'),
            periodType?: string(name='PeriodType'),
          }
        ](name='OrderPeriods'),
        properties?: map[string]any(name='Properties'),
        salePrices?: [ 
          {
            period?: string(name='Period'),
            quota?: string(name='Quota'),
            salePriceItems?: [ 
              {
                price?: float(name='Price'),
                priceType?: string(name='PriceType'),
                tradeType?: string(name='TradeType'),
              }
            ](name='SalePriceItems'),
            sortId?: int32(name='SortId'),
            type?: string(name='Type'),
          }
        ](name='SalePrices'),
        sortId?: int32(name='SortId'),
      }
    ](name='ProductSkus'),
    score?: double(name='Score'),
    shopInfo?: {
      emails?: string(name='Emails'),
      id?: long(name='Id'),
      name?: string(name='Name'),
      telephones?: [ string ](name='Telephones'),
      wangWangs?: [ 
        {
          remark?: string(name='Remark'),
          userName?: string(name='UserName'),
        }
      ](name='WangWangs'),
    }(name='ShopInfo'),
    shortDescription?: string(name='ShortDescription'),
    status?: string(name='Status'),
    supplierPk?: long(name='SupplierPk'),
    type?: string(name='Type'),
    useCount?: long(name='UseCount'),
    version?: string(name='Version'),
  }(name='Result'),
  synchro?: boolean(name='Synchro'),
}

model DescribeProductResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DescribeProductResponseBody(name='body'),
}

async function describeProductWithOptions(request: DescribeProductRequest, runtime: Util.RuntimeOptions): DescribeProductResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.callerBid)) {
    body['CallerBid'] = request.callerBid;
  }
  if (!Util.isUnset(request.callerParentId)) {
    body['CallerParentId'] = request.callerParentId;
  }
  if (!Util.isUnset(request.callerType)) {
    body['CallerType'] = request.callerType;
  }
  if (!Util.isUnset(request.callerUid)) {
    body['CallerUid'] = request.callerUid;
  }
  if (!Util.isUnset(request.clientIp)) {
    body['ClientIp'] = request.clientIp;
  }
  if (!Util.isUnset(request.code)) {
    body['Code'] = request.code;
  }
  if (!Util.isUnset(request.eagleEyeRpcId)) {
    body['EagleEyeRpcId'] = request.eagleEyeRpcId;
  }
  if (!Util.isUnset(request.eagleEyeTraceId)) {
    body['EagleEyeTraceId'] = request.eagleEyeTraceId;
  }
  if (!Util.isUnset(request.eagleEyeUserData)) {
    body['EagleEyeUserData'] = request.eagleEyeUserData;
  }
  if (!Util.isUnset(request.ownerId)) {
    body['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.queryDraft)) {
    body['QueryDraft'] = request.queryDraft;
  }
  if (!Util.isUnset(request.requestId)) {
    body['RequestId'] = request.requestId;
  }
  if (!Util.isUnset(request.securityToken)) {
    body['SecurityToken'] = request.securityToken;
  }
  if (!Util.isUnset(request.sourceIp)) {
    body['SourceIp'] = request.sourceIp;
  }
  if (!Util.isUnset(request.stsTokenCallerBid)) {
    body['StsTokenCallerBid'] = request.stsTokenCallerBid;
  }
  if (!Util.isUnset(request.stsTokenCallerUid)) {
    body['StsTokenCallerUid'] = request.stsTokenCallerUid;
  }
  if (!Util.isUnset(request.stsTokenPrincipalId)) {
    body['StsTokenPrincipalId'] = request.stsTokenPrincipalId;
  }
  if (!Util.isUnset(request.stsTokenRoleId)) {
    body['StsTokenRoleId'] = request.stsTokenRoleId;
  }
  if (!Util.isUnset(request.stsTokenUserId)) {
    body['StsTokenUserId'] = request.stsTokenUserId;
  }
  if (!Util.isUnset(request.userId)) {
    body['UserId'] = request.userId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'DescribeProduct',
    version = '2018-12-27',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function describeProduct(request: DescribeProductRequest): DescribeProductResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeProductWithOptions(request, runtime);
}

model QueryCommodityByServiceIdRequest {
  pageIndex?: int32(name='PageIndex'),
  pageSize?: int32(name='PageSize'),
  requestId?: string(name='RequestId'),
  serviceIds?: string(name='ServiceIds'),
}

model QueryCommodityByServiceIdResponseBody = {
  code?: string(name='Code'),
  dynamicMessage?: string(name='DynamicMessage'),
  forceFatal?: boolean(name='ForceFatal'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
  result?: map[string]any(name='Result'),
  success?: boolean(name='Success'),
}

model QueryCommodityByServiceIdResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: QueryCommodityByServiceIdResponseBody(name='body'),
}

async function queryCommodityByServiceIdWithOptions(request: QueryCommodityByServiceIdRequest, runtime: Util.RuntimeOptions): QueryCommodityByServiceIdResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.pageIndex)) {
    body['PageIndex'] = request.pageIndex;
  }
  if (!Util.isUnset(request.pageSize)) {
    body['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.requestId)) {
    body['RequestId'] = request.requestId;
  }
  if (!Util.isUnset(request.serviceIds)) {
    body['ServiceIds'] = request.serviceIds;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'QueryCommodityByServiceId',
    version = '2018-12-27',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function queryCommodityByServiceId(request: QueryCommodityByServiceIdRequest): QueryCommodityByServiceIdResponse {
  var runtime = new Util.RuntimeOptions{};
  return queryCommodityByServiceIdWithOptions(request, runtime);
}

model QueryCommodityBySupplierUidRequest {
  pageIndex?: int32(name='PageIndex'),
  pageSize?: int32(name='PageSize'),
  requestId?: string(name='RequestId'),
  supplierUid?: string(name='SupplierUid'),
}

model QueryCommodityBySupplierUidResponseBody = {
  code?: string(name='Code'),
  dynamicMessage?: string(name='DynamicMessage'),
  forceFatal?: boolean(name='ForceFatal'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
  result?: [ 
    {
      code?: string(name='Code'),
      iconUrl?: string(name='IconUrl'),
      name?: string(name='Name'),
      versionList?: [ string ](name='VersionList'),
    }
  ](name='Result'),
  success?: boolean(name='Success'),
}

model QueryCommodityBySupplierUidResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: QueryCommodityBySupplierUidResponseBody(name='body'),
}

async function queryCommodityBySupplierUidWithOptions(request: QueryCommodityBySupplierUidRequest, runtime: Util.RuntimeOptions): QueryCommodityBySupplierUidResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.pageIndex)) {
    body['PageIndex'] = request.pageIndex;
  }
  if (!Util.isUnset(request.pageSize)) {
    body['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.requestId)) {
    body['RequestId'] = request.requestId;
  }
  if (!Util.isUnset(request.supplierUid)) {
    body['SupplierUid'] = request.supplierUid;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'QueryCommodityBySupplierUid',
    version = '2018-12-27',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function queryCommodityBySupplierUid(request: QueryCommodityBySupplierUidRequest): QueryCommodityBySupplierUidResponse {
  var runtime = new Util.RuntimeOptions{};
  return queryCommodityBySupplierUidWithOptions(request, runtime);
}

model QueryCommodityInfoRequest {
  commodityCode?: string(name='CommodityCode'),
}

model QueryCommodityInfoResponseBody = {
  code?: string(name='Code'),
  dynamicMessage?: string(name='DynamicMessage'),
  forceFatal?: boolean(name='ForceFatal'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
  result?: {
    commodityBaseInfo?: {
      auditStatus?: int32(name='AuditStatus'),
      channel?: int32(name='Channel'),
      code?: string(name='Code'),
      gmtPublished?: string(name='GmtPublished'),
      name?: string(name='Name'),
      saleMode?: int32(name='SaleMode'),
      saleWay?: int32(name='SaleWay'),
      specList?: [ 
        {
          code?: string(name='Code'),
          commodityId?: long(name='CommodityId'),
          description?: string(name='Description'),
          gmtCreated?: string(name='GmtCreated'),
          gmtModified?: string(name='GmtModified'),
          id?: long(name='Id'),
          moduleList?: [ 
            {
              code?: string(name='Code'),
              commodityId?: long(name='CommodityId'),
              description?: string(name='Description'),
              gmtCreated?: string(name='GmtCreated'),
              gmtModified?: string(name='GmtModified'),
              id?: long(name='Id'),
              name?: string(name='Name'),
              properties?: map[string]string(name='Properties'),
              saleWay?: int32(name='SaleWay'),
              sortIndex?: int32(name='SortIndex'),
              specId?: long(name='SpecId'),
            }
          ](name='ModuleList'),
          name?: string(name='Name'),
          properties?: map[string]string(name='Properties'),
          sortIndex?: int32(name='SortIndex'),
        }
      ](name='SpecList'),
      status?: int32(name='Status'),
      supplierPK?: string(name='SupplierPK'),
      type?: int32(name='Type'),
    }(name='CommodityBaseInfo'),
    supplierBaseInfo?: {
      aliyunId?: string(name='Aliyun_id'),
      aliyunKp?: string(name='Aliyun_kp'),
      city?: int32(name='City'),
      companyName?: string(name='Company_name'),
      createdOn?: string(name='Created_on'),
      id?: long(name='Id'),
      isvKey?: string(name='Isv_key'),
      province?: int32(name='Province'),
      saleMode?: int32(name='SaleMode'),
      status?: int32(name='Status'),
      type?: int32(name='Type'),
    }(name='SupplierBaseInfo'),
  }(name='Result'),
  success?: boolean(name='Success'),
}

model QueryCommodityInfoResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: QueryCommodityInfoResponseBody(name='body'),
}

async function queryCommodityInfoWithOptions(request: QueryCommodityInfoRequest, runtime: Util.RuntimeOptions): QueryCommodityInfoResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.commodityCode)) {
    body['CommodityCode'] = request.commodityCode;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'QueryCommodityInfo',
    version = '2018-12-27',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function queryCommodityInfo(request: QueryCommodityInfoRequest): QueryCommodityInfoResponse {
  var runtime = new Util.RuntimeOptions{};
  return queryCommodityInfoWithOptions(request, runtime);
}

model QueryImageIdRequest {
  commodityCode?: string(name='CommodityCode'),
  imageVersion?: string(name='ImageVersion'),
  pageIndex?: int32(name='PageIndex'),
  pageSize?: int32(name='PageSize'),
  regionNo?: string(name='RegionNo'),
  requestId?: string(name='RequestId'),
}

model QueryImageIdResponseBody = {
  code?: string(name='Code'),
  dynamicMessage?: string(name='DynamicMessage'),
  forceFatal?: boolean(name='ForceFatal'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
  result?: [ string ](name='Result'),
  success?: boolean(name='Success'),
}

model QueryImageIdResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: QueryImageIdResponseBody(name='body'),
}

async function queryImageIdWithOptions(request: QueryImageIdRequest, runtime: Util.RuntimeOptions): QueryImageIdResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.commodityCode)) {
    body['CommodityCode'] = request.commodityCode;
  }
  if (!Util.isUnset(request.imageVersion)) {
    body['ImageVersion'] = request.imageVersion;
  }
  if (!Util.isUnset(request.pageIndex)) {
    body['PageIndex'] = request.pageIndex;
  }
  if (!Util.isUnset(request.pageSize)) {
    body['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.regionNo)) {
    body['RegionNo'] = request.regionNo;
  }
  if (!Util.isUnset(request.requestId)) {
    body['RequestId'] = request.requestId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'QueryImageId',
    version = '2018-12-27',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function queryImageId(request: QueryImageIdRequest): QueryImageIdResponse {
  var runtime = new Util.RuntimeOptions{};
  return queryImageIdWithOptions(request, runtime);
}

model QuerySupplierDetailBySupplierUidRequest {
  pageIndex?: int32(name='PageIndex'),
  pageSize?: int32(name='PageSize'),
  requestId?: string(name='RequestId'),
  supplierUids?: string(name='SupplierUids'),
}

model QuerySupplierDetailBySupplierUidResponseBody = {
  code?: string(name='Code'),
  dynamicMessage?: string(name='DynamicMessage'),
  forceFatal?: boolean(name='ForceFatal'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
  result?: map[string]ResultValue(name='Result'),
  success?: boolean(name='Success'),
}

model QuerySupplierDetailBySupplierUidResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: QuerySupplierDetailBySupplierUidResponseBody(name='body'),
}

async function querySupplierDetailBySupplierUidWithOptions(request: QuerySupplierDetailBySupplierUidRequest, runtime: Util.RuntimeOptions): QuerySupplierDetailBySupplierUidResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.pageIndex)) {
    body['PageIndex'] = request.pageIndex;
  }
  if (!Util.isUnset(request.pageSize)) {
    body['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.requestId)) {
    body['RequestId'] = request.requestId;
  }
  if (!Util.isUnset(request.supplierUids)) {
    body['SupplierUids'] = request.supplierUids;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'QuerySupplierDetailBySupplierUid',
    version = '2018-12-27',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function querySupplierDetailBySupplierUid(request: QuerySupplierDetailBySupplierUidRequest): QuerySupplierDetailBySupplierUidResponse {
  var runtime = new Util.RuntimeOptions{};
  return querySupplierDetailBySupplierUidWithOptions(request, runtime);
}

